home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / System / XFD / Developer / Sources / ASM / CRUNCH2A.a < prev    next >
Encoding:
Text File  |  2001-09-16  |  3.2 KB  |  148 lines

  1. *******************************************************
  2. **             XFD external decruncher               **
  3. **              for CRUNCH2A cruncher                **
  4. **             adapted by Wanted Team                **
  5. *******************************************************
  6.  
  7.         INCLUDE    "AINCLUDE:IncDirs.i"
  8.         INCLUDE    "libraries/xfdmaster.i"
  9.  
  10. ; xfdForeman structure MUST be first thing in all external decrunchers
  11.  
  12. ForeMan        moveq    #-1,d0        ;security
  13.         rts
  14.         dc.l    XFDF_ID        ;id
  15.         dc.w    1        ;version
  16.         dc.w    0
  17.         dc.l    0,0        ;private
  18.         dc.l    S_CRUNCH2A    ;first slave
  19.  
  20. **************************************************
  21.  
  22. ; xfdSlave structure: this one doesn't support data scanning
  23.  
  24. S_CRUNCH2A        dc.l    0        ;no more slaves
  25.         dc.w    2        ;version
  26.         dc.w    39        ;master version
  27.         dc.l    N_CRUNCH2A    ;name
  28.         dc.w    XFDPFF_DATA!XFDPFF_RECOGLEN!XFDPFF_USERTARGET
  29.         dc.w    0
  30.         dc.l    RB_CRUNCH2A    ;recog buffer
  31.         dc.l    DB_CRUNCH2A    ;decrunch buffer
  32.         dc.l    0        ;recog segment
  33.         dc.l    0        ;decrunch segment
  34.         dc.w    0,0
  35.         dc.l    32+2
  36.  
  37.         dc.b    "$VER: CRUNCH2A 2.1 (09.06.2001) by Wanted Team",0
  38. N_CRUNCH2A    dc.b    "CRUNCH2A data cruncher",0
  39.         even
  40.  
  41. ;-------------------------------------------------
  42.  
  43. ; Recog buffer function: receives buffer + length in a0/d0
  44.  
  45. RB_CRUNCH2A    btst    #0,D0
  46.         bne.b    Exit
  47.         cmp.l    #"CRUN",(A0)+
  48.         bne.b    Exit
  49.         cmp.l    #"CH2A",(A0)+
  50.         bne.b    Exit
  51.         move.l    4(A0),D1
  52.         beq.b    Exit
  53.         move.l    D1,xfdrr_MinTargetLen(A1)
  54.         moveq    #100,D0
  55.         sub.l    D0,D1
  56.         move.l    D1,xfdrr_FinalTargetLen(A1)
  57.         move.l    20(A0),D1
  58.         beq.b    Exit
  59.         moveq    #10,D0
  60.         add.l    D0,D1
  61.         move.l    D1,xfdrr_MinSourceLen(A1)
  62.         moveq    #1,D0
  63.         rts    
  64. Exit        moveq    #0,D0
  65.         rts
  66.  
  67. ;-------------------------------------------------
  68.  
  69. ; Decrunch buffer function: receives bufferinfo in a0
  70. ; This style requires xfdmaster.library V39
  71. DB_CRUNCH2A    movem.l    D2-D7/A2-A6,-(A7)
  72.         move.l    A0,A5
  73.         move.l    xfdbi_UserTargetBuf(A5),A1
  74.         move.l    xfdbi_SourceBuffer(A5),A6
  75.         bsr.b    D_CRUNCH2A
  76.         moveq    #1,D0
  77.         movem.l    (A7)+,D2-D7/A2-A6
  78.         rts
  79.  
  80. ;-------------------------------------------------
  81.  
  82. ; Decruncher from "Street Gang" (c) 1987 by Time Warp/Rainbow Arts
  83.  
  84. D_CRUNCH2A    MOVE.B    8(A6),D2
  85.         MOVE.B    9(A6),D3
  86.         MOVE.B    10(A6),D4
  87.         MOVEA.L    12(A6),A3            ; depacked length
  88. ;        MOVEA.L    $14(A6),A5            ; jump address
  89. ;        MOVEA.L    $18(A6),A4            ; end of depack address
  90. ;        MOVEA.L    $1C(A6),A2            ; packed length
  91.         LEA    $20(A6),A0
  92.         add.l    A1,A3
  93.         MOVEA.L    A3,A4
  94.         LEA    lbW001E64(PC),A2
  95.         LEA    -$64(A4),A4
  96. lbC001E22    CMPA.L    A1,A4
  97.         BLE.B    lbC001E9E
  98.         MOVEQ    #0,D0
  99.         MOVE.B    (A0)+,D0
  100.         TST.B    D0
  101.         BMI.S    lbC001E50
  102.         CMP.W    #$7F,D0
  103.         BEQ.S    lbC001E40
  104.         SUBQ.W    #1,D0
  105. lbC001E38    MOVE.B    (A0)+,(A1)+
  106.         DBRA    D0,lbC001E38
  107.         BRA.S    lbC001E22
  108. lbC001E40    MOVE.B    (A0)+,D1
  109.         ROL.W    #8,D1
  110.         MOVE.B    (A0)+,D1
  111.         SUBQ.W    #1,D1
  112. lbC001E48    MOVE.B    (A0)+,(A1)+
  113.         DBRA    D1,lbC001E48
  114.         BRA.S    lbC001E22
  115. lbC001E50    MOVE.W    D0,D1
  116.         ANDI.W    #$1F,D0
  117.         ROR.W    #4,D1
  118.         ANDI.W    #6,D1
  119.         MOVEA.L    A2,A3
  120.         ADDA.W    0(A2,D1.W),A3
  121.         JMP    (A3)
  122. lbW001E64    dc.w    8,$14,$20,$2E
  123.         ADDQ.W    #1,D0
  124. lbC001E6E    MOVE.B    D2,(A1)+
  125.         DBRA    D0,lbC001E6E
  126.         BRA.B    lbC001E22
  127.         ADDQ.W    #1,D0
  128. lbC001E7A    MOVE.B    D3,(A1)+
  129.         DBRA    D0,lbC001E7A
  130.         BRA.B    lbC001E22
  131. lbC001E84    ADDQ.W    #1,D0
  132.         MOVE.B    (A0)+,D1
  133. lbC001E88    MOVE.B    D1,(A1)+
  134.         DBRA    D0,lbC001E88
  135.         BRA.B    lbC001E22
  136.         LSL.W    #8,D0
  137.         MOVE.B    (A0)+,D0
  138.         ADDI.W    #$20,D0
  139.         BRA.B    lbC001E84
  140. lbC001E9E    TST.B    D4
  141.         BNE.S    lbC001EAC
  142.         MOVEQ    #0,D0
  143. lbC001EAA    RTS
  144. lbC001EAC    MOVEQ    #-1,D0
  145.         RTS
  146.  
  147.         END
  148.